home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / hack / 3_1_3 / sys / amiga / amirip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-03  |  17.2 KB  |  718 lines

  1. /*    SCCS Id: @(#)amirip.c    3.2    93/04/26    */
  2. /* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1991, 1992, 1993. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6. #include <exec/types.h>
  7. #include <exec/io.h>
  8. #include <exec/alerts.h>
  9. #include <exec/devices.h>
  10. #include <devices/console.h>
  11. #include <devices/conunit.h>
  12. #include <graphics/gfxbase.h>
  13. #include <graphics/gfxmacros.h>
  14. #include <intuition/intuition.h>
  15. #include <libraries/dosextens.h>
  16. #include <ctype.h>
  17. #include <string.h>
  18. #include "winami.h"
  19.  
  20. #ifdef AMII_GRAPHICS
  21.  
  22. #undef  NULL
  23. #define NULL    0
  24.  
  25. #ifdef AZTEC_C
  26. # include <functions.h>
  27. #else
  28. # include <proto/dos.h>
  29. # include <proto/exec.h>
  30. # include <proto/console.h>
  31. # include <proto/diskfont.h>
  32.  
  33. /* terrible kludge */
  34. /* this is why prototypes should have ONLY types in them! */
  35. # undef red
  36. # undef green
  37. # undef blue
  38. # undef index
  39. # include <proto/graphics.h>
  40.  
  41. # include <proto/intuition.h>
  42. #endif /* AZTEC_C */
  43.  
  44. static void grass ( int x , int y );
  45. static void strand ( int x , int y , int dir );
  46. static void tomb_text ( char *p );
  47. void draw_moon(int phase);
  48. void FDECL( amii_outrip, ( winid, int ) );
  49.  
  50. extern char *killed_by_prefix[];
  51. struct Window *ripwin;
  52.  
  53. #define STONE_LINE_LEN 18   /* # chars that fit on one line
  54.                  * (note 1 ' ' border)
  55.                  */
  56. #define MOONSIZE    30
  57.  
  58. static struct stabstuff
  59. {
  60.     short x1,y0;
  61. }
  62. stab[]=
  63. {
  64.     {0,0}, {0,1}, {0,2}, {1,3}, {2,4},
  65.     {3,5}, {5,6}, {7,7}, {9,8}, {11,9}
  66. };
  67.  
  68. static struct
  69. {
  70.     int x, y;    /* center of moon */
  71. }
  72. moon[]=
  73. {
  74. /* 0-7, left to right, 4 is full and just right of center
  75. 0-3 hollow to left, 5-7 hollow to right (DONT GO OFF THE SCREEN EDGE!) */
  76.     { 50, 70, },
  77.     { 120, 60, },
  78.     { 190, 50, },
  79.     { 260, 40, },
  80.     { 330, 30, },
  81.     { 410, 40, },
  82.     { 480, 50, },
  83.     { 550, 60, },
  84. };
  85.  
  86. unsigned short dirtpat[ 7 ][ 3 ][ 8 ]=
  87. {
  88. {
  89.  {0xb8a0, 0xc124, 0xa60f, 0x7894, 0x1152, 0x0ec1, 0x14c0, 0xa921, },
  90.  {0x4611, 0x365b, 0x5030, 0x0460, 0x44a0, 0xd106, 0x0131, 0x4282, },
  91.  {0xb9ee, 0xc9a4, 0xafcf, 0xfb9f, 0xbb5f, 0x2ef9, 0xfece, 0xbd7d, },
  92. },
  93.  
  94. {
  95.  {0x1258, 0x1015, 0xd430, 0x0488, 0x1402, 0x1040, 0x22e3, 0x8ce8, },
  96.  {0x00a4, 0x818a, 0x2a45, 0x6255, 0x49a8, 0xe69a, 0x9118, 0x1215, },
  97.  {0xff5b, 0x7e75, 0xd5ba, 0x9daa, 0xb657, 0x1965, 0x6ee7, 0xedea, },
  98. },
  99.  
  100. {
  101.  {0x9958, 0x0164, 0x80c8, 0xa660, 0x0412, 0x0025, 0x22ab, 0x2512, },
  102.  {0x64a4, 0xb292, 0x5525, 0x489d, 0x73c0, 0x7e8a, 0x0514, 0xd2ad, },
  103.  {0x9b5b, 0x4d6d, 0xaada, 0xb762, 0x8c3f, 0x8175, 0xfaeb, 0x2d52, },
  104. },
  105.  
  106. {
  107.  {0x8f41, 0xca1e, 0x29c2, 0xa4c0, 0x5481, 0x94d8, 0x9702, 0x0914, },
  108.  {0x608c, 0x05c0, 0x4425, 0x1936, 0x2a3e, 0x4203, 0x4064, 0x54c0, },
  109.  {0x9f73, 0xfa3f, 0xbbda, 0xe6c9, 0xd5c1, 0xbdfc, 0xbf9b, 0xab3f, },
  110. },
  111.  
  112. {
  113.  {0x4000, 0xd52b, 0x1010, 0x5008, 0x40c1, 0x4057, 0x014a, 0x606c, },
  114.  {0xa900, 0x2810, 0x0a85, 0x8fc6, 0x3406, 0xbfa0, 0xf020, 0x9d10, },
  115.  {0x56ff, 0xd7ef, 0xf57a, 0x7039, 0xcbf9, 0x405f, 0x0fdf, 0x62ef, },
  116. },
  117.  
  118. {
  119.  {0x8368, 0x0480, 0x900e, 0xf41f, 0x2e24, 0xfa03, 0x0397, 0x895c, },
  120.  {0x5814, 0x1022, 0x4ca0, 0x0300, 0x0042, 0x0078, 0xf048, 0x6683, },
  121.  {0xa7eb, 0xefdd, 0xb35f, 0xfcff, 0xffbd, 0xff87, 0x0fb7, 0x997c, },
  122. },
  123.  
  124. {
  125.  {0x4228, 0x0050, 0xa016, 0x42a3, 0x341c, 0x46a2, 0x23d3, 0x4001, },
  126.  {0xb515, 0x6383, 0x13c8, 0x8d5c, 0x0822, 0x1149, 0x4400, 0x8728, },
  127.  {0x4aea, 0x9c7c, 0xec37, 0x72a3, 0xf7dd, 0xeeb6, 0xbbff, 0x78d7, },
  128. },
  129. };
  130.  
  131. static USHORT stonepat[] =
  132. {
  133.     0x8242,
  134.     0x2421,
  135.     0x1888,
  136.     0x4112,
  137.     0x2444,
  138.     0x8218,
  139.     0x4181,
  140.     0x1824,
  141. };
  142.  
  143. static USHORT moundpat[] =
  144. {
  145.     0x5235,
  146.     0xd7c6,
  147.     0x1298,
  148.     0x34a7,
  149.     0x2736,
  150.     0x2c54,
  151.     0xdc93,
  152.     0xc551,
  153. };
  154.  
  155. #define DEATH_LINE  10
  156. #define YEAR_LINE   15
  157.  
  158. static int horizon;
  159. static struct RastPort *rp;
  160. static unsigned char tomb_line;
  161.  
  162. extern struct amii_DisplayDesc *amiIDisplay;
  163. extern struct Screen *HackScreen;
  164. extern int havelace;
  165.  
  166. #undef  BLACK
  167. #undef  WHITE
  168. #undef  BROWN
  169. #undef  GREEN
  170.  
  171. #define BLACK   0
  172. #define WHITE   1
  173. #define BROWN   2
  174. #define GREY    3
  175. #define GREEN   4
  176. #define DKGRN   5
  177.  
  178. static unsigned short zeropalette[] = {
  179.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  180. };
  181. static unsigned short toppalette[] = {
  182.     0x0000, 0x0EEF, 0x0730, 0x0778, 0x0082, 0x0573, 0x0000, 0x0000,
  183. };
  184.  
  185. #define AREA_SIZE   200
  186. static WORD areabuffer[ AREA_SIZE ];
  187.  
  188. static struct NewWindow newwin =
  189. {
  190.     0,0,640,200,1,0,
  191.     MOUSEBUTTONS|VANILLAKEY|NOCAREREFRESH,
  192.     BORDERLESS|ACTIVATE|SMART_REFRESH,
  193.     NULL,NULL,(UBYTE*)NULL,NULL,NULL,-1,-1,-1,-1,CUSTOMSCREEN
  194. };
  195.  
  196. int wh; /* was local in outrip, but needed for SCALE macro */
  197.  
  198. #define WIN_DEPTH ripwin->RPort->BitMap->Depth
  199. /*TODO: should use real algorithm to get circles */
  200. #define SCALE(x) ((wh<300)?(x):((x)*2))
  201. #define MOONSX  MOONSIZE
  202. #define MOONSY  ((SCALE(MOONSIZE)/2)-4)
  203.  
  204. void
  205. draw_moon(int phase)
  206. {
  207.     int x;
  208.     int off_c_x=MOONSX+10;    /* moon center x in srp */
  209.     int off_c_y=MOONSY;        /* moon center y in srp */
  210.     int blit_urhx=10;        /* upper right hand corner for blit */
  211.     int blit_urhy=0;
  212.     int blit_width=MOONSX*2;    /* sizes for blit */
  213.     int blit_height=MOONSY*2+1;    /* +1 - hmm (rounding? 0 base?)*/
  214.  
  215.     /* set up scratch rastport */
  216.     struct BitMap sbm;
  217.     struct RastPort srp;
  218.     struct AreaInfo ainfo;
  219.     WORD abuf[100];
  220.     struct TmpRas atr;
  221.     PLANEPTR ap = NULL;
  222.  
  223. #define    XSZ        8
  224. #define    YSZ        8
  225.  
  226.     /*TODO: sizes here are bigger than needed */
  227.     InitBitMap(&sbm,WIN_DEPTH,MOONSIZE*XSZ,MOONSIZE*YSZ);
  228.     for(x=0;x<WIN_DEPTH;x++){
  229.     sbm.Planes[x]=(PLANEPTR)AllocRaster(MOONSIZE*XSZ,MOONSIZE*YSZ);
  230.     if(!sbm.Planes[x])goto free;
  231.     }
  232.     InitRastPort(&srp);
  233.     srp.BitMap=&sbm;
  234.     memset( abuf, 0, sizeof( abuf ) );        /* Must be zeroed */
  235.     InitArea(&ainfo,abuf,sizeof(abuf)/5);    /* 5 bytes per vertex */
  236.     srp.AreaInfo= &ainfo;
  237.     ap=AllocRaster(320,200);
  238.     if(!ap)goto free;
  239. #ifdef AZTEC_C
  240.     /*
  241.      * Aztec, in their infinite wisdom, require a char * as the
  242.      * second argument.
  243.      */
  244.     InitTmpRas(&atr, (char *)ap, RASSIZE(320,200));
  245. #else
  246.     InitTmpRas(&atr,ap,RASSIZE(320,200));
  247. #endif
  248.     srp.TmpRas = &atr;
  249.     SetAfPt(rp,(UWORD *)NULL,0);
  250.     SetRast(&srp,BLACK);
  251.  
  252.     switch(phase){
  253.     case 0: /* new moon - no image */
  254.     break;
  255.     case 1: /* waxing crescent */
  256.     SetAPen(&srp,WHITE);
  257.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  258.     AreaEnd(&srp);
  259.     SetAPen(&srp,BLACK);
  260.     AreaEllipse(&srp,off_c_x+10,off_c_y,MOONSX,MOONSY);
  261.     AreaEnd(&srp);
  262.     break;
  263.  
  264.     case 2: /* 1st quarter */
  265.     SetAPen(&srp,WHITE);
  266.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  267.     AreaEnd(&srp);
  268.     SetAPen(&srp,BLACK);
  269.     RectFill(&srp,off_c_x,0,MOONSIZE*4-1,MOONSIZE*2-1);
  270.     break;
  271.     case 3: /* gibbous */
  272.     SetAPen(&srp,WHITE);
  273.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  274.     AreaEnd(&srp);
  275.     SetAPen(&srp,BLACK);
  276.     RectFill(&srp,off_c_x,0,MOONSIZE*4-1,MOONSIZE*2-1);
  277.     SetAPen(&srp,WHITE);
  278.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX/2,MOONSY);
  279.     AreaEnd(&srp);
  280.     break;
  281.     case 4: /* full */
  282.     SetAPen(&srp,WHITE);
  283.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  284.     AreaEnd(&srp);
  285.     break;
  286.     case 5: /* gibbous */
  287.     SetAPen(&srp,WHITE);
  288.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  289.     AreaEnd(&srp);
  290.     SetAPen(&srp,BLACK);
  291.     RectFill(&srp,0,0,off_c_x,MOONSIZE*2-1);
  292.     SetAPen(&srp,WHITE);
  293.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX/2,MOONSY);
  294.     AreaEnd(&srp);
  295.     break;
  296.     case 6: /* last quarter */
  297.     SetAPen(&srp,WHITE);
  298.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  299.     AreaEnd(&srp);
  300.     SetAPen(&srp,BLACK);
  301.     RectFill(&srp,0,0,off_c_x,MOONSIZE*4-1+10);
  302.     break;
  303.     case 7: /* waning crescent */
  304.     SetAPen(&srp,WHITE);
  305.     AreaEllipse(&srp,off_c_x,off_c_y,MOONSX,MOONSY);
  306.     AreaEnd(&srp);
  307.     SetAPen(&srp,BLACK);
  308.     AreaEllipse(&srp,off_c_x-10,off_c_y,MOONSX,MOONSY);
  309.     AreaEnd(&srp);
  310.     break;
  311.     }
  312.     /*move rastport into window (so that there are no stars "in" the moon)*/
  313.     /* draw black circle in window rport */
  314.     SetAPen(rp,BLACK);
  315.     AreaEllipse( rp, moon[phase].x,moon[phase].y,MOONSX,MOONSY);
  316.     AreaEnd(rp);
  317.  
  318.     if(phase != 0){
  319.     /*move scratch to window: set all white, ignore black (in src)*/
  320.     ClipBlit(&srp,blit_urhx,blit_urhy,
  321.       rp,moon[phase].x-(blit_width/2),moon[phase].y-(blit_height/2),
  322.       blit_width,blit_height,0xe0);
  323.     }
  324.  
  325. free:
  326.     for(x=0;x<WIN_DEPTH;x++)
  327.     {
  328.     if(sbm.Planes[x])
  329.         FreeRaster(sbm.Planes[x],MOONSIZE*XSZ,MOONSIZE*YSZ);
  330.     }
  331.     if(ap)FreeRaster(ap,320,200);
  332. }
  333. #undef WIN_DEPTH
  334.  
  335. void
  336. amii_outrip( tmpwin, how )
  337. winid tmpwin;
  338. int how;
  339. {
  340.     int done, rtxth;
  341.     struct IntuiMessage *imsg;
  342.     struct AreaInfo areaInfo;
  343.     PLANEPTR planeptr;
  344.     struct TmpRas tmpRas;
  345.     int i;
  346.     register char *dpx;
  347.     char buf[ 200 ];
  348.     register int x;
  349.     int line, phase, c, offset, tw, ww;
  350.  
  351.     /* Use the users display size */
  352.     newwin.Height = amiIDisplay->ypix - newwin.TopEdge;
  353.     newwin.Width = amiIDisplay->xpix;
  354.     newwin.Screen = HackScreen;
  355.  
  356.     ripwin = OpenWindow( &newwin );
  357.     if( !ripwin ){
  358.     return;
  359.     }
  360.  
  361.     rp= ripwin->RPort;
  362.     wh = ripwin->Height;
  363.     ww = ripwin->Width;
  364.     if( !( planeptr = AllocRaster( ww, wh ) ) )
  365.     return;
  366.  
  367. #ifdef AZTEC_C
  368.     InitTmpRas( &tmpRas, (char *) planeptr, RASSIZE( ww, wh ) );
  369. #else
  370.     InitTmpRas( &tmpRas, planeptr, RASSIZE( ww, wh ) );
  371. #endif
  372.     rp->TmpRas = &tmpRas;
  373.  
  374.     for( i = 0; i < AREA_SIZE; ++i )
  375.     areabuffer[ i ] = 0;
  376.     InitArea( &areaInfo, areabuffer, (AREA_SIZE*2)/5);
  377.     rp->AreaInfo = &areaInfo;
  378.  
  379.     LoadRGB4( &HackScreen->ViewPort, zeropalette, 8L );
  380.  
  381.     horizon=ripwin->Height*2/3;
  382.  
  383.     /* sky */
  384.     SetDrMd(rp,JAM1);
  385.     SetAPen( rp, BLACK );
  386.     RectFill(rp,0,0,ripwin->Width,horizon);
  387.  
  388.     /* ground */
  389.     SetDrMd( rp, JAM2 );
  390.     SetAfPt( rp, dirtpat[random()%7], -3 );
  391.     SetAPen( rp, 255 );
  392.     SetBPen( rp, 0 );
  393.     RectFill( rp, 0, horizon+1, ripwin->Width, ripwin->Height );
  394.     SetAfPt( rp, (UWORD *)NULL, 0 );
  395.  
  396.     /* stars */
  397.     SetAPen(rp,WHITE);
  398.     for(c=d(30,40);c;c--)
  399.     WritePixel(rp,rn2(ripwin->Width-1),rn2(horizon));
  400.  
  401.     /* moon (NB destroys area fill pattern) */
  402.     phase = phase_of_the_moon() % 8;
  403.     draw_moon(phase);
  404.  
  405.     /* grass */
  406.     SetAPen(rp,GREEN);
  407.     for( x = 5; x < ripwin->Width-5; x+=5+rn2(8))
  408.     grass(x, horizon+5 );
  409.     for( x = 5; x < ripwin->Width-5; x+=5+rn2(10))
  410.     grass(x, horizon+10 );
  411.     for( x = 5; x < ripwin->Width-5; x+=5+rn2(15))
  412.     grass(x, horizon+10 );
  413.     for( x = 5; x < ripwin->Width-5; x+=5+rn2(20))
  414.     grass(x, horizon+10 );
  415.  
  416.     /* fence - horizontal, then vertical, each with a moonlit side */
  417.     SetAPen(rp,GREY);
  418.     Move(rp,0,horizon-SCALE(20));
  419.     Draw(rp,ripwin->Width,horizon-SCALE(20));
  420.     Move(rp,0,horizon+30);
  421.     Draw(rp,ripwin->Width,horizon+30);
  422.  
  423.     offset=(phase<4)?-1:1;
  424.     for(x=30;x<ripwin->Width;x+=50)
  425.     {
  426.     Move(rp,x,horizon-SCALE(25));
  427.     Draw(rp,x,horizon+35);
  428.     Move(rp,x-offset,horizon-SCALE(25));
  429.     Draw(rp,x-offset,horizon+35);
  430.     Move(rp,x-(2*offset),horizon-SCALE(25));
  431.     Draw(rp,x-(2*offset),horizon+35);
  432.     }
  433.  
  434.  
  435.     if(phase)SetAPen(rp,WHITE); /* no vertical white if no moon */
  436.     Move(rp,0,horizon-SCALE(20)-1);
  437.     Draw(rp,ripwin->Width,horizon-SCALE(20)-1);
  438.     Move(rp,0,horizon+29);
  439.     Draw(rp,ripwin->Width,horizon+29);
  440.  
  441.     if(phase!=0 && phase!=4){
  442.     SetAPen(rp,WHITE);
  443.     } else {
  444.     SetAPen(rp,GREY);   /* no hor. white if no or full moon */
  445.     }
  446.     for(x=30;x<ripwin->Width;x+=50)
  447.     {
  448.     Move(rp,x+offset,horizon-SCALE(25));
  449.     Draw(rp,x+offset,horizon+35);
  450.     Move(rp,x+(2*offset),horizon-SCALE(25));
  451.     Draw(rp,x+(2*offset),horizon+35);
  452.     }
  453.  
  454.     /* Put together death description */
  455.     switch (killer_format) {
  456.     default:
  457.     impossible("bad killer format?");
  458.     case KILLED_BY_AN:
  459.     Strcpy(buf, killed_by_prefix[how]);
  460.     Strcat(buf, an(killer));
  461.     break;
  462.     case KILLED_BY:
  463.     Strcpy(buf, killed_by_prefix[how]);
  464.     Strcat(buf, killer);
  465.     break;
  466.     case NO_KILLER_PREFIX:
  467.     Strcpy(buf, killer);
  468.     break;
  469.     }
  470.  
  471.     tw = TextLength(rp,buf,STONE_LINE_LEN) + 40;
  472.  
  473.     {
  474.     char *p=buf;
  475.     int x, tmp;
  476.     for(x=STONE_LINE_LEN;x;x--)*p++='W';
  477.     *p='\0';
  478.     tmp = TextLength(rp,buf,STONE_LINE_LEN) + 40;
  479.     tw = max( tw, tmp);
  480.     }
  481.  
  482.     SetAPen( rp, phase ? BLACK : GREY );
  483.     SetBPen( rp, phase ? WHITE : BLACK );
  484.     SetDrMd( rp, JAM2 );
  485.     SetAfPt( rp, stonepat, 3 );
  486.  
  487.     /* There are 5 lines of text on the stone. */
  488.     rtxth = ripwin->RPort->TxHeight * 5;
  489.  
  490.     /* Do shadow ellipse on stone */
  491.     if( phase < 4 )
  492.     AreaEllipse(rp,ripwin->Width/2-3,horizon-rtxth,tw/2+3,tw/6);
  493.     else if( phase > 4 )
  494.     AreaEllipse(rp,ripwin->Width/2+3,horizon-rtxth,tw/2+3,tw/6);
  495.     else
  496.     AreaEllipse(rp,ripwin->Width/2,horizon-rtxth-2,tw/2+3,tw/6);
  497.     AreaEnd( rp );
  498.  
  499.     /* Top ellipse on stone */
  500.     SetAPen( rp, BLACK );
  501.     SetBPen( rp, GREY );
  502.     AreaEllipse(rp,ripwin->Width/2,horizon-rtxth,tw/2,tw/6);
  503.     AreaEnd( rp );
  504.  
  505.     /* Body of stone */
  506.     RectFill(rp,ripwin->Width/2-tw/2,horizon-rtxth,ripwin->Width/2+tw/2,
  507.       horizon-rtxth+15+(rp->TxHeight+1)*8);
  508.  
  509.     SetAPen( rp, phase ? BROWN : GREY );
  510.     SetBPen( rp, phase ? GREY : BROWN );
  511.     SetAfPt( rp, stonepat, 3 );
  512.  
  513. #if 0
  514.     AreaMove( rp, ripwin->Width/2-tw/2, horizon-rtxth+15+(rp->TxHeight+1)*8 );
  515.     AreaDraw( rp, ripwin->Width/2-tw/4, horizon-rtxth+((ripwin->Height > 200)
  516.       ? 55 : 35)+(rp->TxHeight+1)*8 );
  517.     AreaDraw( rp, ripwin->Width/2+tw, horizon-rtxth+((ripwin->Height > 200)
  518.       ? 55 : 35)+(rp->TxHeight+1)*8 );
  519.     AreaDraw( rp, ripwin->Width/2+tw/2, horizon-rtxth+15+(rp->TxHeight+1)*8 );
  520.     AreaEnd( rp );
  521.  
  522.     SetAfPt( rp, stonepat, 3 );
  523.  
  524. #endif
  525.     /* Draw shadow on correct side of stone */
  526.     SetAPen( rp, phase ? BLACK : GREY );
  527.     SetBPen( rp, phase ? WHITE : BLACK );
  528.     if( phase < 4 )
  529.     {
  530.     AreaMove( rp, ripwin->Width/2-tw/2-6, horizon-rtxth );
  531.     AreaDraw( rp, ripwin->Width/2-tw/2-6,
  532.       horizon-rtxth+15+(rp->TxHeight+1)*8-4 );
  533.     AreaDraw( rp, ripwin->Width/2-tw/2-1,
  534.       horizon-rtxth+15+(rp->TxHeight+1)*8 );
  535.     AreaDraw( rp, ripwin->Width/2-tw/2-1, horizon-rtxth );
  536.     }
  537.     else if( phase > 4 )
  538.     {
  539.     AreaMove( rp, ripwin->Width/2+tw/2+6, horizon-rtxth );
  540.     AreaDraw( rp, ripwin->Width/2+tw/2+6,
  541.       horizon-rtxth+15+(rp->TxHeight+1)*8-4 );
  542.     AreaDraw( rp, ripwin->Width/2+tw/2+1,
  543.       horizon-rtxth+15+(rp->TxHeight+1)*8 );
  544.     AreaDraw( rp, ripwin->Width/2+tw/2+1, horizon-rtxth );
  545.     }
  546.     AreaEnd( rp );
  547.  
  548.     SetAfPt( rp, (UWORD *)NULL, 0 );
  549.     SetDrPt( rp, ~0 );
  550.  
  551.     tomb_line=0;
  552.     SetBPen(rp,GREY);
  553.     SetDrMd(rp,JAM1);
  554.     tomb_text("REST");
  555.     tomb_text("IN");
  556.     tomb_text("PEACE");
  557.  
  558.     /* Put name on stone */
  559.     Sprintf(buf, "%s", plname);
  560.     buf[STONE_LINE_LEN] = 0;
  561.     tomb_text(buf);
  562.  
  563.     /* Put $ on stone */
  564.     Sprintf(buf, "%ld Au", u.ugold);
  565.     buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
  566.     tomb_text(buf);
  567.  
  568.     /* Put together death description */
  569.     switch (killer_format) {
  570.     default:
  571.     impossible("bad killer format?");
  572.     case KILLED_BY_AN:
  573.     Strcpy(buf, killed_by_prefix[how]);
  574.     Strcat(buf, an(killer));
  575.     break;
  576.     case KILLED_BY:
  577.     Strcpy(buf, killed_by_prefix[how]);
  578.     Strcat(buf, killer);
  579.     break;
  580.     case NO_KILLER_PREFIX:
  581.     Strcpy(buf, killer);
  582.     break;
  583.     }
  584.  
  585.     /* Put death type on stone */
  586.     for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++)
  587.     {
  588.     register int i,i0;
  589.     char tmpchar;
  590.  
  591.     if ( (i0=strlen(dpx)) > STONE_LINE_LEN)
  592.     {
  593.         for(i=STONE_LINE_LEN;((i0 > STONE_LINE_LEN) && i); i--)
  594.         {
  595.         if(dpx[i] == ' ')
  596.             i0 = i;
  597.         }
  598.         if(!i)
  599.         i0 = STONE_LINE_LEN;
  600.     }
  601.  
  602.     tmpchar = dpx[i0];
  603.     dpx[i0] = 0;
  604.     tomb_text(dpx);
  605.  
  606.     if (tmpchar != ' ')
  607.     {
  608.         dpx[i0] = tmpchar;
  609.         dpx= &dpx[i0];
  610.     }
  611.     else
  612.     {
  613.         dpx= &dpx[i0+1];
  614.     }
  615.     }
  616.  
  617.     /* Put year on stone */
  618.     Sprintf(buf, "%4d", getyear());
  619.     tomb_text(buf);
  620.  
  621.     LoadRGB4( &HackScreen->ViewPort, toppalette, 8L );
  622.  
  623.     done = 0;
  624.     while( !done )
  625.     {
  626.     WaitPort( ripwin->UserPort );
  627.     while( imsg = (struct IntuiMessage *)GetMsg(ripwin->UserPort) )
  628.     {
  629.         switch( imsg->Class )
  630.         {
  631.         case MOUSEBUTTONS:
  632.         case VANILLAKEY:
  633.             done = 1;
  634.             break;
  635.         }
  636.         ReplyMsg( (struct Message *)imsg );
  637.     }
  638.     }
  639.  
  640.     if( planeptr ) FreeRaster( planeptr, ww, wh );
  641.     rp->TmpRas = NULL;
  642.     Forbid();
  643.     while( imsg = (struct IntuiMessage *)GetMsg( ripwin->UserPort ) )
  644.     ReplyMsg( (struct Message *)imsg );
  645.     CloseWindow( ripwin );
  646.     ripwin = NULL;
  647.     Permit();
  648.     LoadRGB4( &HackScreen->ViewPort, flags.amii_curmap, 8L );
  649. }
  650.  
  651. static void grass(x,y)
  652. register int x,y;
  653. {
  654.     register int ct=rn2(5)+3;
  655.     register int c;
  656.     x-=2;
  657.     for(c=ct;c;c--)
  658.     {
  659.     strand(x,y,(c>ct/2)?1:-1);
  660.     x+=2;
  661.     }
  662. }
  663.  
  664. static void strand(x,y,dir)
  665.    register int x,y;
  666.    register int dir;    /* which way the wind blows :-) */
  667. {
  668.     register int i;
  669.     register struct RastPort *nrp = rp;
  670.     register struct stabstuff *st;
  671.     for(i=rn2(10);i>=0;i--)
  672.     {
  673.     st = &stab[i];
  674.     WritePixel(nrp,x+st->x1*dir,y-st->y0);
  675.     }
  676. }
  677.  
  678. static void tomb_text(p)
  679. char *p;
  680. {
  681.     char buf[STONE_LINE_LEN*2];
  682.     int l;
  683.     /*int i;*/
  684.  
  685.     if( !*p )
  686.     return;
  687.     sprintf(buf," %s ",p);
  688.     l=TextLength(rp,buf,strlen(buf));
  689.     ++tomb_line;
  690.  
  691.     SetAPen(rp,WHITE);
  692.     Move(rp,(ripwin->Width/2)-(l/2)-1, 
  693.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  694.     Text(rp,buf,strlen(buf));
  695.  
  696.     SetAPen(rp,WHITE);
  697.     Move(rp,(ripwin->Width/2)-(l/2)+1,
  698.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  699.     Text(rp,buf,strlen(buf));
  700.  
  701.     SetAPen(rp,WHITE);
  702.     Move(rp,(ripwin->Width/2)-(l/2),
  703.       ((tomb_line-6)*(rp->TxHeight+1))+horizon - 1);
  704.     Text(rp,buf,strlen(buf));
  705.  
  706.     SetAPen(rp,WHITE);
  707.     Move(rp,(ripwin->Width/2)-(l/2),
  708.       ((tomb_line-6)*(rp->TxHeight+1))+horizon + 1);
  709.     Text(rp,buf,strlen(buf));
  710.  
  711.     SetAPen(rp,BLACK);
  712.     Move(rp,(ripwin->Width/2)-(l/2),
  713.       ((tomb_line-6)*(rp->TxHeight+1))+horizon);
  714.     Text(rp,buf,strlen(buf));
  715. }
  716.  
  717. #endif /* AMII_GRAPHICS */
  718.